package processcontrol;

/**
 * @author shkstart
 * @date 2022/4/8 - 22:47
 */
public class IfTest06 {
    public static void main(String[] args) {
/*        int sum;
        int i;
        for ( i = 1; i <= 100; i++ ) {
            if (i % 2 != 0 ) {
                System.out.println(i);
                sum += i;
            }
        }
        System.out.println(sum);*/
//        编译不通过原因：在for循环之前没给sum赋值，、有可能在for循环通过条件阶段直接跳出循环
//                       造成sum无法成功赋值从而编译失败

        int sum;
        int i;
        //for ( i = 1; i <= 100; i++ ) {
            if (4 % 2 != 0 ) {
                System.out.println(i);
                sum = 1;
            }else {
                sum = 2;
            }
       // }
        System.out.println(sum);
    }
}
